package com.example.service;

import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Data
@Component
public class MyBean implements InitializingBean {

    private static final Logger logger = LoggerFactory.getLogger(MyBean.class);

    private String property;

    public MyBean() {
        logger.info("MyBean constructor called");
    }

    @PostConstruct
    public void postConstruct() {
        logger.info("MyBean @PostConstruct method called");

        init();
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        logger.info("MyBean afterPropertiesSet method called");
    }

    public void init() {
        logger.info("MyBean custom init-method called");
    }

    // 模拟业务逻辑方法
    public void performTask() {
        logger.info("MyBean performTask method called with property: {}", property);
    }
}
